package org.sbbs.app.demo.service.impl;

import java.util.concurrent.ConcurrentLinkedQueue;

import org.sbbs.app.demo.dao.DemoSysDbLogDao;
import org.sbbs.app.demo.model.DemoSysDbLog;
import org.sbbs.app.demo.service.DemoSysDbLogManager;
import org.sbbs.base.service.impl.BaseManagerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Administrator
 */
@Service( "demoSysDbLogManager" )
public class DemoSysDbLogManagerImpl
    extends BaseManagerImpl<DemoSysDbLog, Long>
    implements DemoSysDbLogManager {
    private DemoSysDbLogDao demoSysDbLogDao;

    private ConcurrentLinkedQueue logQueue = new ConcurrentLinkedQueue();

    @Autowired
    public DemoSysDbLogManagerImpl( DemoSysDbLogDao demoSysDbLogDao ) {
        super( demoSysDbLogDao );
        this.demoSysDbLogDao = demoSysDbLogDao;
    }

    @Override
    public void addLog( DemoSysDbLog log ) {
        this.logQueue.add( log );

    }

    @Override
    public void rewriteLogToDb() {

        this.demoSysDbLogDao.rewriteLogToDb( logQueue );
        this.logQueue.clear();
    }

}